﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SampleApplication.Models
{
    public class PersonRepository : RepositoryBase<Person, long>
    {
        public PersonRepository(IUnitOfWork unit) : base(unit)
        {
        }

        public IQueryable<Person> Search(string name)
        {
            var query = this.FindAll();
            if (!string.IsNullOrEmpty(name))
            {
                query = query.Where(p => p.Name.IndexOf(name) != -1);
            }
            return query.OrderBy(p => p.PersonID);
        }
    }
}
